package com.leyou.item.client;

import com.leyou.common.pojo.PageResult;
import com.leyou.item.dto.SpecGroupDTO;
import com.leyou.item.dto.SpuDTO;
import com.leyou.item.pojo.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient("item-service")  //通过nacos查找服务名称，来进行远程调用
public interface ItemClient {
    @GetMapping("/spu/page")
    public PageResult<SpuDTO>spuPageQuery(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "key", required = false) String key,
            @RequestParam(value = "saleable", required = false) boolean saleable
    );

    @GetMapping("/sku/of/spu")
    public List<Sku> findSkusBySpuId(@RequestParam("id") Long id);

    @GetMapping("/spec/params")
    public List<SpecParam>findSpecParam(
            @RequestParam(value = "gid", required = false) Long gid,
            @RequestParam(value = "cid", required = false) Long cid,
            @RequestParam(value = "searching", required = false) Boolean searching
    );

    @GetMapping("/spu/detail")
     SpuDetail findSpuDetailBySpuId(@RequestParam("id") Long id);

    @GetMapping("/category/list")
    List<Category>findCategoriesByCids(@RequestParam ("ids") List<Long> ids);

    @GetMapping("/brand/list")
    List<Brand> findBrandsByIds(@RequestParam("ids") List<Long> ids);

    @GetMapping("/spu/{id}")
    SpuDTO findSpuDTOBySpuId(@PathVariable("id") Long id);

    @GetMapping("/spec/of/category")
    public List<SpecGroupDTO> findSpecGroupDTOByCid(@RequestParam("id") Long id);

    @GetMapping("/brand/{id}")
     Brand findById(
            @PathVariable("id") Long id
    );
    @GetMapping("/sku/list")
    public List<Sku> findByIds(
            @RequestParam("ids") List<Long> ids
    );
    @PutMapping("/stock/minus")
    public Void minusStock(
            @RequestBody Map<Long,Integer> paramap
    );
}
